﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WMemoryProfiler.Memory
{
    class DisposingWrapper<T> : IDisposable where T : IDisposable
    {
        T Instance;
        public T Value
        {
            get { return Instance; }
        }

        bool DisposeOnDispose;

        public DisposingWrapper(T instance, bool bDisposeOnDispose=true)
        {
            Instance = instance;
            DisposeOnDispose = bDisposeOnDispose;
        }



        public void Dispose()
        {
            if( DisposeOnDispose )
            {
                Instance.Dispose();
            }
        }
    }
}
